/**
 * Created by IntelliJ IDEA.
 * User: Tomek
 * Date: 11.10.12
 * Time: 23:49
 * To change this template use File | Settings | File Templates.
 */
package fossilgeom {
import flash.display.Graphics;
import flash.geom.Point;

import mx.containers.Canvas;
import mx.events.FlexEvent;

public class BasicArrow extends Canvas{
    public function BasicArrow()
    {
        super();

        addEventListener(FlexEvent.CREATION_COMPLETE,draw);
    }

    private var _lineHeight:Number = 100;
    private var _lineColor:Number = 0x000000;
    private var _lineAlpha:Number = 1;
    private var _lineThickness:Number = 2;

    public function get lineHeight():Number
    {
        return _lineHeight;
    }
    public function set lineHeight(value:Number):void
    {
        _lineHeight = value;
        draw();
    }

    private var _lineLength:Number = 100;
    public function get lineLength():Number
    {
        return _lineLength;
    }
    public function set lineLength(value:Number):void
    {
        _lineLength = value;
        draw();
    }

    private function draw(event:FlexEvent=null):void
    {
        var origin:Point = new Point(0,0);
        var destination:Point = new Point(lineLength,lineHeight);

        var lineThickness:Number = _lineThickness;
        var lineColor:Number = _lineColor;
        var lineAlpha:Number = _lineAlpha;

        getGraphics().clear();
        getGraphics().beginFill(lineColor,lineAlpha);
        GeomUtils.drawArrow(getGraphics(),origin,destination,
                {shaftThickness:lineThickness,headWidth:10,headLength:15,
                    shaftPosition:.20,edgeControlPosition:.5
                }
        );
    }

    private function getGraphics():Graphics {
        return graphics;
    }


    public function get lineColor():Number {
        return _lineColor;
    }

    public function set lineColor(value:Number):void {
        _lineColor = value;
    }

    public function get lineAlpha():Number {
        return _lineAlpha;
    }

    public function set lineAlpha(value:Number):void {
        _lineAlpha = value;
    }


    public function get lineThickness():Number {
        return _lineThickness;
    }

    public function set lineThickness(value:Number):void {
        _lineThickness = value;
    }
}

}
